#include "queue.h"

Queue::Queue()
{
    _nInitialCapacity=INITIAL_CAPACITY;
    Init();
}

Queue::Queue(int initialCapacity)
{
    _nInitialCapacity=initialCapacity;
    Init();
}

Queue::Queue(ArrayList* list)
{
    _list=list;
}

Queue:: ~Queue()
{
    delete _list;
}

void Queue:: Init()
{
    _list=new ArrayList(_nInitialCapacity);
}

// real realization comes from here:
void Queue:: enqueue(T object)
{
    _list->add(object);
}

// FIFO -queue:
T Queue:: dequeue()
{
    if(_list->size()>=1)
	return _list->deleteElement(0);
    return T(0);
}

int Queue:: size()
{
    return _list->size();
}

bool Queue:: isEmpty()
{
    return _list->isEmpty();
}

T Queue:: get(int index){
    return _list->get(index);
}

void Queue:: deleteAll()
{
    _list->deleteAll();
}

void Queue:: startPos()
{
    _list->startPos();
}

bool Queue:: isAtEnd()
{
    return _list->isAtEnd();
}

T Queue:: getNext()
{
    return _list->getNext();
}

bool Queue:: doesContain(T element)
{
    return (_list->indexOf(element)!=-1);
}
